#!/usr/bin/env node
const path = require('path');
const fs = require('fs');
const program = require('commander');
const pack = require('./pack/pack');
const init = require('./inits/init');
//const start = require('./start/start');
const initial={};

let config = {};

let rootpath=path.resolve();
// 配置文件如果存在则读取
if(fs.existsSync(path.resolve('qguan.config'))){
    //config = require(path.resolve('qguan.config'));
}
if(!config.name||config.name==""){
    config.name=path.basename(rootpath)
}

/*program
    .version('1.0.0','-v, --version')
    .command('init')
    .description('initialize your meet config')
    .action();*/
program .version('0.0.1')
    .option('-l, --lib', '依赖')
    .option('-d, --depot', '发送到仓库')

program
    .command('init [module]')
    .description('generator a new module')
    .action(function(module){
        init (config,module,rootpath)
    });

program
    .command('pack [module]')

    .description('generator a new module')
    .action(function(module){
        let moduleName="";
        if(!module||module==""){
            moduleName=config.name;
        }else {
            moduleName=module;
        }
      pack (config,moduleName,rootpath)
    });
program
    .command('start [module]')
    .description('generator a new module')
    .action(function(module){
       // start (config,module,rootpath)
    });


program.parse(process.argv);